<template>
    <div>
        <div>
            <input type="text" placeholder="请输入用户名" v-model="forms.username"><br>
            <input type="password" placeholder="请输入密码" v-model="forms.pass"><br>
            <button @click="submitForm(forms)">提交</button>
        </div>
    
    </div>
</template>

<script>
    export default {
        data() {
            return {
                forms:{
                    username:"",
                    pass:""
                }
            }
        },
        methods: {
            submitForm(val){
                // console.log(val)
                var {username,pass} = val
                this.$http.post("/login",{username,pass}).then(res=>{
                    // console.log(res.data.auth)//loginAuth=true
                    if(res.data.auth){
                        this.$router.push("/home")
                    }else{
                        alert(res.data.msg)
                    }
                })
            }
        },
    }
</script>

<style scoped>

</style>